// 数字格式化函数

function countFormat(num, digits = 1){
    const si = [
        { value: 1, symbol: "" },
        { value: 1E4, symbol: "万" },
        { value: 1E8, symbol: "亿" },
        { value: 1E20, symbol: "亿+" }
    ]
    const rx = /\.0+$|(\.[0-9]*[1-9])0+$/
    let i
    for (i = si.length - 1; i > 0; i--) {
        if (num >= si[i].value) {
            break
        }
    }
    return (num / si[i].value).toFixed(digits).replace(rx, "$1") + si[i].symbol
}

export default countFormat